package org.jeecg.modules.bim.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.bim.entity.BimPointCloud;
import org.jeecg.modules.bim.service.IBimPointCloudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/bim")
@Api(tags = "bim点云数据")
public class BimPointCloudController {


    @Autowired
    private IBimPointCloudService bimPointCloudService;


    /**
     * 查询
     *
     * @param projectInfoId
     * @return
     */
    @ApiOperation(value = "点云数据列表查询", notes = "点云数据列表查询")
    @GetMapping(value = "pointCloud/query")
    public Result<List<BimPointCloud>> pointCloudList(@RequestParam @ApiParam("工程管理自增id") Integer projectInfoId) {
        List<BimPointCloud> bimPointClouds = bimPointCloudService.pointCloudList(projectInfoId, null);
        return Result.OK(bimPointClouds);
    }

    /**
     * 添加
     *
     * @param bimPointCloud
     * @return
     */
    @AutoLog(value = "点云数据添加")
    @ApiOperation(value = "点云数据添加", notes = "点云数据添加")
    @PostMapping(value = "pointCloud/add")
    public Result<?> addPointCloud(@RequestBody BimPointCloud bimPointCloud) {
        return Result.OK(bimPointCloudService.addPointCloud(bimPointCloud));
    }

    /**
     * 添加
     *
     * @param bimPointCloud
     * @return
     */
    @AutoLog(value = "点云数据编辑")
    @ApiOperation(value = "点云数据编辑", notes = "点云数据编辑")
    @PostMapping(value = "pointCloud/edit")
    public Result<?> editPointCloud(@RequestBody BimPointCloud bimPointCloud) {
        bimPointCloudService.updateById(bimPointCloud);
        return Result.OK(bimPointCloudService.getById(bimPointCloud.getId()));
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "点云数据删除")
    @ApiOperation(value = "点云数据删除", notes = "点云数据删除")
    @DeleteMapping(value = "pointCloud/delete")
    public Result<String> delete(@RequestParam Long id) {
        bimPointCloudService.removeById(id);
        return Result.OK("删除成功！");
    }


}
